#include <bits/stdc++.h>
using namespace std;
class Node{
public:
    int data;
    Node* pNext;
    Node(int d,Node* n = nullptr){
        data = d;
        pNext = nullptr;
    }
};
Node* ReverseList(Node* pHead)
{

    Node* Current_Node = pHead;
    Node* pReversed = nullptr;
    Node* Post_Node = nullptr;
    while(Current_Node!=nullptr)
    {
        Node* Next_Node = Current_Node->pNext;
        if(Next_Node!=nullptr)
        {
            Current_Node->pNext = Post_Node;
            Current_Node = Next_Node->pNext;
            Current_Node = Next_Node;
        }
        pReversed = Current_Node;
    }
    return pReversed;

}
int main()
{
    Node* a = new Node(3);
    Node* b = new Node(4);
    Node* c = new Node(5);
    Node* d = new Node(6);
    a->pNext = b;
    b->pNext = c;
    c->pNext = d;
    Node* head = ReverseList(a);
    while(head->pNext!=nullptr)
    {
        cout<<head->data;
        head = head->pNext;
    }
    delete a,b,c,d;

}